﻿@{
    ViewBag.Title = "PartsForm";
    Layout = "~/Views/Shared/_FlowForm.cshtml";
}
<script>
    var keyValue = request('keyValue');
    //判断是哪个界面打开
    var switchType = request('switchType');
    $(function () {
        initControl();
    })
    function initControl() {
        //类别
        $("#Type").ComboBoxTree({
            url: "../../ResourceManage/RS_DeviceType/GetTreeJson",
            description: "==请选择==",
            height: "230px"
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_DeviceType/GetPartsFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                    $("#Type").ComboBoxTreeSetValue(data.Type);
                }
            });
        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        
        $.SaveForm({
            url: "../../ResourceManage/RS_DeviceType/SavePartsForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                if (!!switchType) switchType = 0;
                switch (switchType) {
                    case 0: $.currentIframe().$("#gridTable3").trigger("reloadGrid"); break;
                    case 1: top.frames["DevicePartDetail"].$("#gridTable").trigger("reloadGrid"); break;
                    default:

                }
             
            }
        })
    }
</script>
<div style="margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <th class="formTitle">设备类别</th>
            <td class="formValue">
                <div id="Type" type="selectTree" class="ui-select"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">零配件名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="Name" type="text" class="form-control" placeholder="请输入零配件名称" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">规格型号<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="ModelNo" type="text" class="form-control" placeholder="请输入规格型号" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">价格<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="Price" type="number" class="form-control" placeholder="请输入价格" value="0" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">生产厂商</th>
            <td class="formValue">
                <input id="Factory" type="text" class="form-control" placeholder="请输入生产厂商" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">附加说明</th>
            <td class="formValue">
                <textarea id="Description" class="form-control" style="height: 70px;"></textarea>
            </td>
        </tr>
    </table>
</div>
